import SMERouter from 'sme-router';
import adminList from "@/views/adminList";
import advList from "@v/advList";
import login from "./views/login.ejs";
import index from "./views/index.ejs";
import Navbar from "./components/Navbar.ejs";
import Siderbar from "./components/Sidebar.ejs";
import Content from "./components/Content.ejs";
import Footer from "./components/Footer.ejs";
window.router = new SMERouter('root',"html5");
router.route("/index",({url},res,next)=>{
	next(index({
		Navbar:Navbar(),// 头部
		Siderbar:Siderbar({url}),
		Content:Content({subRoute:res.subRoute()}),
		Footer:Footer()
	}));
})
// 请求地址为/index/adminList，呈现的内容为：管理员界面
router.route("/index/adminList",(req,res)=>{
	res.render(adminList());
})
// 请求地址为/index/advList，呈现的内容为：广告界面
router.route("/index/advList",(req,res)=>{
	res.render(advList());
})
router.route("/login",(req,res)=>{
	res.render(login());
})
// 找不到匹配的路由地址，重定向至/index/adminList
router.route('*', (req, res, next) => {
	res.redirect('/index/adminList')
})